import os
from flask_migrate import Migrate
from . import create_app, db
from .models import User, Post
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from .main.views import photos

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)

configure_uploads(app, photos)
patch_request_class(app)  # set maximum file size, default is 16MB


@app.shell_context_processor
def make_shell_context():
    return dict(db=db, User=User, Post=Post)


if __name__ == '__main__':
    db.create_all()
    app.run()
